package com.wing.cabinet.controller.websocket;

import lombok.extern.slf4j.Slf4j;

import javax.websocket.*;

@ClientEndpoint
@Slf4j
public class CabinetClient {

    @OnOpen
    public void onOpen(Session session){
      log.info("conn to endpoint "+session.getBasicRemote());
      try{
          session.getBasicRemote().sendText("hello");
      }catch (Exception e){
          log.error("send fail",e);
      }
    }

    @OnMessage
    public void onMessage(String msg){
        log.info("receive msg "+msg);
    }

    @OnError
    public void onError(Throwable e){
        log.error("error",e);
    }

}
